<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>原型的动态性</title>
</head>

<body>
    <script>
        function Person(name, age, job) {
            this.name = name
            this.age = age
            this.job = job
        }

        let person1 = new Person('lilei', 28, 'Java Engineer')
        
        Person.prototype = {
            sayName: function () {
                console.log(`Hello everybody i am ${this.name}`)
            },
            sayAge: function () {
                console.log(`I am ${this.age} years old`)
            }
        }

        let person2 = new Person('lily', 25, 'web Engineer')
        person2.sayName()
        person1.sayName() //报错  
    </script>
</body>

</html>